
const ADD_GUN = 'add';
const REMOVE_GUN = 'minus';

//reducer

export function counter(state=10,action) {
    console.log(action.type)
    console.log(state)
    switch(action.type) {
        case ADD_GUN:
            return state+1
        case REMOVE_GUN:
            return state-1
        default:
            return state
    }
}


export function addGun() {
    return {type:ADD_GUN}
}
export function removeGun() {
    return {type:REMOVE_GUN}
}

export function addGunAsync() {
    return dispatch => {
        setTimeout(()=>{
            dispatch(addGun())
            addGun()
            console.log(addGun())
            console.log('tuolaingtian')
        },2000)
    }
}